struct Solution {}

fn main() {}

impl Solution {
    pub fn maximize_sum(nums: Vec<i32>, k: i32) -> i32 {
        (*nums.iter().max().unwrap() * 2 + k - 1) * k / 2
    }
}